package com.example.john.foodstore;

import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;

/**
 * Created by john on 16/4/17.
 */
public class DishesAdapter extends BaseAdapter{
    private List<Dishes> mydishes;
    private LayoutInflater inflater;

    public List<Dishes> getMydishes() {
        return mydishes;
    }

    public void setMydishes(List<Dishes> mydishes) {
        this.mydishes = mydishes;
    }

    public DishesAdapter(List<Dishes> mydishes, LayoutInflater inflater) {
        this.mydishes = mydishes;
        this.inflater = inflater;
    }

    @Override
    public int getCount() {
        return mydishes.size();
    }

    @Override
    public Object getItem(int position) {
        return mydishes.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView=inflater.inflate(R.layout.dishes_info,null);
        final Dishes dishes = mydishes.get(position);
        TextView dishesName=(TextView)convertView.findViewById(R.id.dishesName);
        dishesName.setText(dishes.getDishesName());
        TextView dishesClass=(TextView)convertView.findViewById(R.id.dishesClass);
        dishesClass.setText(dishes.getDishesClass());
        TextView dishesPrice=(TextView)convertView.findViewById(R.id.dishesPrice);
        dishesPrice.setText(dishes.getDishesPrice());
        ImageView dishesPicture=(ImageView)convertView.findViewById(R.id.dishesPicture);
        dishesPicture.setImageBitmap(dishes.getDishesPicture());
        /*ImageView snap=(ImageView)convertView.findViewById(R.id.snap);
        snap.setImageResource(food.getSnap());
        snap.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.i("john",food.getFoodName()+"....");
           }
        });*/

        return convertView;
    }
}
